"use strict";
{
    class Graph {
        constructor(vertices = 0) {
            this.vertices = vertices;
            this.edges = 0; // 边
            this.adj = [];
            for (let i = 0; i < this.vertices; i++) {
                this.adj[i] = [];
                this.adj[i].push(''); // 自己不可能和自己相连
            }
        }
        addEdge(v, w) {
            this.adj[v].push(w);
            this.adj[w].push(v);
            this.edges++;
        }
        showGraph() {
            for (let i = 0; i < this.vertices; i++) {
                console.log(i + '->');
                for (let j = 0; j < this.vertices; j++) {
                    if (this.adj[j][j] !== undefined) {
                        console.log(this.adj[i][j]);
                    }
                }
                console.log('--------');
            }
        }
    }
    let g = new Graph(5);
    g.addEdge(0, 1);
    g.addEdge(0, 2);
    g.addEdge(1, 3);
    g.addEdge(2, 4);
    g.showGraph();
    // console.log(g.adj)
}
